home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performExtendCurve.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  21.2 KB  |  813 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  22 April 1997
  22. //  Author:         sjt
  23. //
  24. //  Description:
  25. //        Initialize the option values.
  26. //
  27. //  Input Arguments:
  28. //      int action
  29. //        0 - just execute the extend curve operation
  30. //        1 - show the option box dialog
  31. //        2 - drag to shelf
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36. //    Notes:
  37. //        In the future this can be modified to include extend to object
  38. //
  39. global proc extendCurveEnableBoth( string $joinWidget,
  40.                                    string $methodWidget,
  41.                                    string $endWidget,
  42.                                    string $knotsWidget,
  43.                                    string $originalsWidget,
  44.                                    int $priorityEnd )
  45. {
  46.     int $enable;
  47.     if( $priorityEnd ) {
  48.         int $end = `radioButtonGrp -q -select $endWidget`;
  49.         if( 3 == $end ) {
  50.             $enable = 0;
  51.         }
  52.         else {
  53.             $enable = 1;
  54.         }
  55.         radioButtonGrp -edit -enable2 $enable $methodWidget;
  56.         checkBoxGrp -edit -enable $enable $joinWidget;
  57.  
  58.         $enable = `checkBoxGrp -q -value1 $joinWidget`;
  59.         checkBoxGrp -edit -enable $enable $knotsWidget;
  60.         checkBoxGrp -edit -enable $enable $originalsWidget;
  61.     }
  62.     else {
  63.         int $join = `checkBoxGrp -q -value1 $joinWidget`;
  64.         int $method = `radioButtonGrp -q -select $methodWidget`;
  65.         if( $join && (1 == $method)) {
  66.             $enable = 1;
  67.         }
  68.         else {
  69.             $enable = 0;
  70.         }
  71.  
  72.         radioButtonGrp -edit -enable3 $enable $endWidget;
  73.  
  74.         $enable = $join;
  75.         checkBoxGrp -edit -enable $enable $knotsWidget;
  76.         checkBoxGrp -edit -enable $enable $originalsWidget;
  77.     }
  78. }
  79.  
  80. proc setOptionVars(int $forceFactorySettings)
  81. {
  82.     //    Extend Method ( 0 = by distance or 2 = to point ).
  83.     //    Default = 0 = by distance
  84.     //
  85.     if ($forceFactorySettings || !`optionVar -exists extendCurveMethod`) {
  86.         optionVar -intValue extendCurveMethod 0;
  87.     }
  88.  
  89.     //    Extension Type ( 0 = linear or 1 = cicular or 2 = extrapolate ).
  90.     //    Used only if extend method is 0
  91.     //    Default = 0 = linear
  92.     //
  93.     if ($forceFactorySettings || !`optionVar -exists extendCurveType`) {
  94.         optionVar -intValue extendCurveType 0;
  95.     }
  96.  
  97.     //    Extend Distance.
  98.     //    Used only if extend method is 0
  99.     //    Default = 1.00
  100.     //
  101.     if ($forceFactorySettings || !`optionVar -exists extendCurveDistance`) {
  102.         optionVar -floatValue extendCurveDistance 1.0;
  103.     }
  104.  
  105.     //    Extend To Point.
  106.     //    Used only if extend method is 2
  107.     //    Default = 0.0, 0.0, 0.0
  108.     //
  109.     if ($forceFactorySettings || !`optionVar -exists extendCurveToPointX`) {
  110.         optionVar -floatValue extendCurveToPointX 0.0;
  111.     }
  112.     if ($forceFactorySettings || !`optionVar -exists extendCurveToPointY`) {
  113.         optionVar -floatValue extendCurveToPointY 0.0;
  114.     }
  115.     if ($forceFactorySettings || !`optionVar -exists extendCurveToPointZ`) {
  116.         optionVar -floatValue extendCurveToPointZ 0.0;
  117.     }
  118.  
  119.     //    Extend Start ( 1 = start or 0 = end, 2 = both )
  120.     //    Default = 0
  121.     //
  122.     if ($forceFactorySettings || !`optionVar -exists extendCurveStart`) {
  123.         optionVar -intValue extendCurveStart 0;
  124.     }
  125.  
  126.     //    Extend Join ( on = join or off = do not join )
  127.     //    Default = ON
  128.     //
  129.     if ($forceFactorySettings || !`optionVar -exists extendCurveJoin`) {
  130.         optionVar -intValue extendCurveJoin 1;
  131.     }
  132.  
  133.     //    Extend Remove Multiple Knots ( on = remove or off = do not remove )
  134.     //  Used only when joining 
  135.     //    Default = OFF
  136.     //
  137.     if ($forceFactorySettings || !`optionVar -exists extendCurveRemoveMultKnots`) {
  138.         optionVar -intValue extendCurveRemoveMultKnots 1;
  139.     }
  140.  
  141.     //  keep original (for in place operations is on-1 or off-0 )
  142.     //    Used only when joining
  143.     /// Default = 0
  144.     //
  145.     if ($forceFactorySettings || !`optionVar -exists extendCurveKeepOriginal`) {
  146.         optionVar -intValue extendCurveKeepOriginal 0;
  147.     }
  148.  
  149. }
  150.  
  151. //
  152. //  Procedure Name:
  153. //      extendCurveSetup
  154. //
  155. //  Description:
  156. //        Update the state of the option box UI to reflect the extend curve
  157. //        option values.
  158. //
  159. //  Input Arguments:
  160. //      parent               - Top level parent layout of the option box UI.
  161. //                             Required so that UI object names can be 
  162. //                             successfully resolved.
  163. //
  164. //        forceFactorySettings - Whether the option values should be set to
  165. //                             default values.
  166. //
  167. //  Return Value:
  168. //      None.
  169. //
  170. global proc extendCurveSetup( string $parent,
  171.                               int $forceFactorySettings,
  172.                               string $goToTool )
  173. {
  174.     //    Retrieve the option settings
  175.     //
  176.     setOptionVars($forceFactorySettings);
  177.     extendCurveToolSetup( $forceFactorySettings, $goToTool );
  178.  
  179.     setParent $parent;
  180.  
  181.     //    Query the optionVar's and set the values into the controls.
  182.  
  183.     //    Extend Method
  184.     //
  185.     int $method = `optionVar -query extendCurveMethod`;
  186.     radioButtonGrp -e -sl ($method+1) extendCurveMethodBtn;
  187.  
  188.     // extend distance
  189.     floatSliderGrp -edit
  190.         -value `optionVar -query extendCurveDistance`
  191.         extendCurveDistanceSlider;
  192.  
  193.     // extend type
  194.     int $extendType = `optionVar -query extendCurveType`;
  195.     int $realExtendType = $extendType + 1 ;
  196.     radioButtonGrp -edit
  197.         -select $realExtendType
  198.         extendCurveTypeBtn;
  199.  
  200.     // extend point
  201.     float $x = `optionVar -q extendCurveToPointX`;
  202.     float $y = `optionVar -q extendCurveToPointY`;
  203.     float $z = `optionVar -q extendCurveToPointZ`;
  204.     floatFieldGrp -e -v1 $x extendCurveToPointFloatFieldGrp;
  205.     floatFieldGrp -e -v2 $y extendCurveToPointFloatFieldGrp;
  206.     floatFieldGrp -e -v3 $z extendCurveToPointFloatFieldGrp;
  207.  
  208.  
  209.     // extend start and join
  210.     //
  211.     int $join = `optionVar -query extendCurveJoin`;
  212.     int $start = `optionVar -query extendCurveStart`;
  213.  
  214.     // convert from value to button number
  215.     // ( 1 = start or 0 = end, 2 = both )
  216.     switch( $start ) {
  217.       case 0:
  218.         $start = 2;
  219.         break;
  220.       case 1:
  221.         $start = 1;
  222.         break;
  223.       case 2:
  224.       default:
  225.         $start = 3;
  226.         break;
  227.     }
  228.  
  229.     radioButtonGrp -e
  230.         extendCurveMethodBtn;
  231.  
  232.     radioButtonGrp -edit
  233.         -select $start
  234.         extendCurveStartBtn;
  235.  
  236.     // Extend join
  237.     //
  238.     checkBoxGrp -edit
  239.         -value1 $join
  240.         extendCurveJoinBox;
  241.  
  242.     // Remove Multiple Knots
  243.     //
  244.     checkBoxGrp -edit
  245.         -value1 `optionVar -query extendCurveRemoveMultKnots`
  246.         -enable ($join && (3 != $start))
  247.         extendCurveRemoveMultKnotsBox;
  248.  
  249.     // Keep original.
  250.     //
  251.     checkBoxGrp -edit
  252.         -value1 `optionVar -query extendCurveKeepOriginal`
  253.         -enable ($join && (3 != $start))
  254.         extendCurveKeepOriginalBox;
  255.  
  256.     extendCurveEnableBoth( "extendCurveJoinBox",
  257.                            "extendCurveMethodBtn",
  258.                            "extendCurveStartBtn",
  259.                            "extendCurveRemoveMultKnotsBox",
  260.                            "extendCurveKeepOriginalBox",
  261.                            0 );
  262.  
  263.     // Do the visibility here (distance vs. point):
  264.     if( 0 == $method ) {
  265.         tabLayout -e -st extendCurveDistance_tab extendCurveMethodOptions;
  266.     }
  267.     else {
  268.         tabLayout -e -st extendCurveToPoint_tab extendCurveMethodOptions;
  269.     }
  270.  
  271.     if( "" != $goToTool ) { 
  272.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  273.           scriptToolExtraWidget;
  274.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  275.           scriptToolExtraWidget;
  276.     }
  277. }
  278.  
  279. //
  280. //  Procedure Name:
  281. //      extendCurveCallback
  282. //
  283. //  Description:
  284. //        Update the option values with the current state of the option box UI.
  285. //
  286. //  Input Arguments:
  287. //      parent - Top level parent layout of the option box UI.  Required so
  288. //               that UI object names can be successfully resolved.
  289. //
  290. //        doIt   - Whether the command should execute.
  291. //
  292. //  Return Value:
  293. //      None.
  294. //
  295. global proc extendCurveCallback(string $parent, int $doIt, string $goToTool)
  296. {
  297.     if( "" != $goToTool ) {
  298.         optionVar -iv extendCurveEuc `scriptCtx -q -euc $goToTool`;
  299.         optionVar -iv extendCurveLac `scriptCtx -q -lac $goToTool`;
  300.     }
  301.     setParent $parent;
  302.  
  303.     //    Set the optionVar's from the control values, and then
  304.     //    perform the command.
  305.  
  306.     //    Extend Method.
  307.     //
  308.     int $method = `radioButtonGrp -query -select extendCurveMethodBtn`;
  309.     int $saveMethod = $method - 1 ;
  310.     optionVar -intValue extendCurveMethod $saveMethod;
  311.  
  312.     if( $saveMethod == 0 ) {
  313.         // Extend Type
  314.         //
  315.         int $extendType = `radioButtonGrp -query -select extendCurveTypeBtn`;
  316.         int $saveExtendType = $extendType - 1 ;
  317.         optionVar -intValue extendCurveType $saveExtendType;
  318.  
  319.         // extend distance
  320.         //
  321.         optionVar -floatValue extendCurveDistance
  322.             `floatSliderGrp -query -value extendCurveDistanceSlider`;
  323.     }
  324.     else {
  325.         //    extend to point.
  326.         //
  327.         float $x = `floatFieldGrp -q -v1 extendCurveToPointFloatFieldGrp` ;
  328.         float $y = `floatFieldGrp -q -v2 extendCurveToPointFloatFieldGrp` ;
  329.         float $z = `floatFieldGrp -q -v3 extendCurveToPointFloatFieldGrp` ;
  330.         optionVar -floatValue extendCurveToPointX $x ;
  331.         optionVar -floatValue extendCurveToPointY $y ;
  332.         optionVar -floatValue extendCurveToPointZ $z ;
  333.     }
  334.  
  335.     // Start or end or both
  336.     // ( 1 = start or 0 = end, 2 = both )
  337.     int $start = `radioButtonGrp -query -select extendCurveStartBtn`;
  338.  
  339.     // convert from button number to value
  340.     switch( $start ) {
  341.       case 1:
  342.         $start = 1;
  343.         break;
  344.       case 2:
  345.         $start = 0;
  346.         break;
  347.       case 3:
  348.       default:
  349.         $start = 2;
  350.         break;
  351.     }
  352.     optionVar -intValue extendCurveStart $start;
  353.  
  354.     // Join
  355.     //
  356.     optionVar -intValue extendCurveJoin 
  357.         `checkBoxGrp -query -value1 extendCurveJoinBox`;
  358.  
  359.     // Remove Multiple knots
  360.     //
  361.     optionVar -intValue extendCurveRemoveMultKnots 
  362.         `checkBoxGrp -query -value1 extendCurveRemoveMultKnotsBox`;
  363.  
  364.     // Keep original.
  365.     //
  366.     optionVar -intValue extendCurveKeepOriginal
  367.         `checkBoxGrp -query -value1 extendCurveKeepOriginalBox`;
  368.  
  369.     if (1 == $doIt) {
  370.         performExtendCurve( 0, $goToTool ); 
  371.         string $tmpCmd = "performExtendCurve( 0, \"" + $goToTool + "\")";
  372.         addToRecentCommandQueue $tmpCmd "Extend Curve";
  373.     }
  374.     else if( $doIt ) {
  375.         setToolTo $goToTool;
  376.     }
  377. }
  378.  
  379. //
  380. //  Procedure Name:
  381. //      createExtendCurveUI
  382. //
  383. //  Description:
  384. //      Fill the contents of the option box for extendCurve command.
  385. //
  386. //  Input Arguments:
  387. //      The name of the parent layout.
  388. //
  389. //  Return Value:
  390. //      None.
  391. //
  392. proc createExtendCurveUI(string $parent, int $inTheTool, string $goToTool)
  393. {
  394.     setParent $parent;
  395.  
  396.     string $methodWidget = `radioButtonGrp -label "Extend Method"
  397.         -numberOfRadioButtons 2
  398.         -label1 "Distance" -da1 0
  399.         -label2 "Point" -da2 2
  400.         extendCurveMethodBtn`;
  401.  
  402.     tabLayout -tabsVisible false extendCurveMethodOptions;
  403.         columnLayout extendCurveDistance_tab;
  404.             radioButtonGrp -label "Extension Type"
  405.                 -numberOfRadioButtons 3
  406.                 -label1 "Linear" -da1 0
  407.                 -label2 "Circular" -da2 1
  408.                 -label3 "Extrapolate" -da3 2
  409.                 extendCurveTypeBtn;
  410.  
  411.             floatSliderGrp -label "Distance"
  412.                 -field true
  413.                 -min 0.0
  414.                 -max 100.0
  415.                 extendCurveDistanceSlider;
  416.         setParent ..;
  417.  
  418.         columnLayout extendCurveToPoint_tab;
  419.             floatFieldGrp -l "Point To Extend To"
  420.             -nf 3
  421.             extendCurveToPointFloatFieldGrp;
  422.         setParent ..;
  423.     setParent ..;
  424.  
  425.     separator;
  426.  
  427.     string $endWidget = `radioButtonGrp -label "Extend Curve at"
  428.             -numberOfRadioButtons 3
  429.             -label1 "Start" -da1 1 -enable1 1
  430.             -label2 "End" -da2 0 -enable2 1 
  431.             -label3 "Both" -da3 0 -enable3 1
  432.             extendCurveStartBtn`;
  433.  
  434.         string $joinWidget = `checkBoxGrp -label ""
  435.             -numberOfCheckBoxes 1
  436.             -label1 "Join to Original"
  437.             extendCurveJoinBox`;
  438.  
  439.         string $knotsWidget = `checkBoxGrp -label ""
  440.             -numberOfCheckBoxes 1
  441.             -label1 "Remove Multiple Knots"
  442.             extendCurveRemoveMultKnotsBox`;
  443.  
  444.         string $originalsWidget = `checkBoxGrp -label ""
  445.             -numberOfCheckBoxes 1
  446.             -label1 "Keep Original"
  447.             extendCurveKeepOriginalBox`;
  448.  
  449.     radioButtonGrp -edit
  450.         -onCommand1 (
  451.                 "tabLayout -e -selectTab extendCurveDistance_tab " +
  452.                 "extendCurveMethodOptions;"
  453.                 + "extendCurveEnableBoth"
  454.                 + " " + $joinWidget
  455.                 + " " + $methodWidget
  456.                 + " " + $endWidget
  457.                 + " " + $knotsWidget
  458.                 + " " + $originalsWidget + " 0;"
  459.             )
  460.         -onCommand2 (
  461.                 "tabLayout -e -selectTab extendCurveToPoint_tab " +
  462.                 "extendCurveMethodOptions;"
  463.                 + "extendCurveEnableBoth"
  464.                 + " " + $joinWidget
  465.                 + " " + $methodWidget
  466.                 + " " + $endWidget
  467.                 + " " + $knotsWidget
  468.                 + " " + $originalsWidget + " 0;"
  469.             )
  470.         $methodWidget;
  471.  
  472.     radioButtonGrp -edit
  473.         -onCommand1 (
  474.                 "extendCurveEnableBoth"
  475.                 + " " + $joinWidget
  476.                 + " " + $methodWidget
  477.                 + " " + $endWidget
  478.                 + " " + $knotsWidget
  479.                 + " " + $originalsWidget + " 1;"
  480.             )
  481.         -onCommand2 (
  482.                 "extendCurveEnableBoth"
  483.                 + " " + $joinWidget
  484.                 + " " + $methodWidget
  485.                 + " " + $endWidget
  486.                 + " " + $knotsWidget
  487.                 + " " + $originalsWidget + " 1;"
  488.             )
  489.         -onCommand3 (
  490.                 "extendCurveEnableBoth"
  491.                 + " " + $joinWidget
  492.                 + " " + $methodWidget
  493.                 + " " + $endWidget
  494.                 + " " + $knotsWidget
  495.                 + " " + $originalsWidget + " 1;"
  496.             )
  497.         $endWidget;
  498.  
  499.     checkBoxGrp -edit
  500.         -onCommand (
  501.                 "extendCurveEnableBoth"
  502.                 + " " + $joinWidget
  503.                 + " " + $methodWidget
  504.                 + " " + $endWidget
  505.                 + " " + $knotsWidget
  506.                 + " " + $originalsWidget + " 0;"
  507.             )
  508.         -offCommand (
  509.                 "extendCurveEnableBoth"
  510.                 + " " + $joinWidget
  511.                 + " " + $methodWidget
  512.                 + " " + $endWidget
  513.                 + " " + $knotsWidget
  514.                 + " " + $originalsWidget + " 0;"
  515.             )
  516.         $joinWidget;
  517.  
  518.     if( $inTheTool ) {
  519.         separator;
  520.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  521.           -l1 "Exit on Completion"
  522.           -v1 off
  523.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  524.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  525.  
  526.           -l2 "Auto Completion"
  527.           -v2 on
  528.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  529.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  530.           scriptToolExtraWidget;
  531.     }
  532. }
  533.  
  534.  
  535. //
  536. //  Procedure Name:
  537. //      extendCurveOptions
  538. //
  539. //  Description:
  540. //        Construct the option box UI.  Involves accessing the standard option
  541. //        box and customizing the UI accordingly.
  542. //
  543. //  Input Arguments:
  544. //      None.
  545. //
  546. //  Return Value:
  547. //      None.
  548. //
  549. proc extendCurveOptions( int $inTheTool, string $goToTool )
  550. {
  551.     //    Name of the command for this option box.
  552.     //
  553.     string $commandName = "extendCurve";
  554.  
  555.     //    Build the option box actions.
  556.     //
  557.     string $callback = ($commandName + "Callback");
  558.     string $setup = ($commandName + "Setup");
  559.  
  560.     //  The value returned is the name of the layout to be used as
  561.     //    the parent for the option box UI.
  562.     //
  563.     global string $gOptionBoxActionToolItem;
  564.     $gOptionBoxActionToolItem = "modelWithToolExtendCurve";
  565.     global string $gOptionBoxActionToolItemCB;
  566.     $gOptionBoxActionToolItemCB = "extendCurveToolScript 3";
  567.  
  568.     string $layout = getOptionBox();
  569.     setParent $layout;
  570.     
  571.     //    Pass the command name to the option box.
  572.     //
  573.     //    Any default option box behavior based on the command name is set 
  574.     //    up with this call.  For example, updating the 'Help' menu item with
  575.     //    the name of the command.
  576.     //
  577.     setOptionBoxCommandName($commandName);
  578.     
  579.     //    Activate the default UI template so that the layout of this 
  580.     //    option box is consistent with the layout of the rest of the 
  581.     //    application.
  582.     //
  583.     setUITemplate -pushTemplate DefaultTemplate;
  584.  
  585.     //    Turn on the wait cursor.
  586.     //
  587.     waitCursor -state 1;
  588.  
  589.     //    RECOMMENDATION:  Place the UI in a scroll layout.  If the 
  590.     //    option box window is ever resized such that it's entire 
  591.     //    contents is not visible then the scroll bars provided by the
  592.     //    scroll layout will allow the user to access the hidden UI.
  593.     //
  594.     tabLayout -scr true -tv false;
  595.     
  596.     string $parent = `columnLayout -adjustableColumn 1`;
  597.     
  598.     //  Create the UI for the tab that is initially visible.
  599.     //
  600.     createExtendCurveUI($parent, $inTheTool, $goToTool);
  601.  
  602.     //    Turn off the wait cursor.
  603.     //
  604.     waitCursor -state 0;
  605.     
  606.     //    Deactivate the default UI template.
  607.     //
  608.     setUITemplate -popTemplate;
  609.  
  610.     //    Provide more descriptive labels for the buttons.  This is not 
  611.     //    necessary, but in some cases, for example, a button labelled 
  612.     //    'Create' may be more meaningful to the user than one labelled
  613.     //    'Apply'.
  614.     //
  615.     //  Disable those buttons that are not applicable to the option box.
  616.     //
  617.     //    Attach actions to those buttons that are applicable to the option
  618.     //    box.  Note that the 'Close' button has a default action attached 
  619.     //    to it that will hide the window.  If a a custom action is
  620.     //    attached to the 'Close' button then be sure to call the 'hide the
  621.     //    option box' procedure within the custom action so that the option
  622.     //    box is hidden properly.
  623.  
  624.     //    'ExtendCurve' button.
  625.     //
  626.     string $applyBtn = getOptionBoxApplyBtn();
  627.     if( $inTheTool ) {
  628.         button -edit -l "Extend Tool"
  629.             -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  630.             $applyBtn;
  631.     }
  632.     else {
  633.         button -edit -l "Extend"
  634.             -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  635.             $applyBtn;
  636.     }
  637.  
  638.     //    'Save' button.
  639.     //
  640.     string $saveBtn = getOptionBoxSaveBtn();
  641.     button -edit 
  642.         -command ($callback + " " + $parent + " 0 \"" +
  643.                   $goToTool + "\"; hideOptionBox")
  644.         $saveBtn;
  645.  
  646.     //    'Reset' button.
  647.     //
  648.     string $resetBtn = getOptionBoxResetBtn();
  649.     button -edit 
  650.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  651.         $resetBtn;
  652.  
  653.     //    Set the option box title.
  654.     //
  655.     if( $inTheTool ) {
  656.         setOptionBoxTitle("Extend Curve Tool Options");
  657.     }
  658.     else {
  659.         setOptionBoxTitle("Extend Curve Options");
  660.     }
  661.  
  662.     //    Customize the 'Help' menu item text.
  663.     //
  664.     setOptionBoxHelpTag( "ExtendCurve" );
  665.  
  666.     //    Set the current values of the option box.
  667.     //
  668.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  669.     
  670.     //    Show the option box.
  671.     //
  672.     showOptionBox();
  673. }
  674.  
  675. //
  676. //  Procedure Name:
  677. //      extendCurveHelp
  678. //
  679. //  Description:
  680. //        Return a short description about this command.
  681. //
  682. //  Input Arguments:
  683. //      None.
  684. //
  685. //  Return Value:
  686. //      string.
  687. //
  688. proc string extendCurveHelp()
  689. {
  690.     return 
  691.     "  Command: extendCurve - extends a curve\n" +
  692.     "Selection: a curve ";    
  693. }
  694.  
  695. //
  696. //  Procedure Name:
  697. //      assembleCmd
  698. //
  699. //  Description:
  700. //        Construct the command that will apply the option box values.
  701. //
  702. //  Input Arguments:
  703. //      None.
  704. //
  705. //  Return Value:
  706. //      The extendCurve command string.
  707. //
  708. proc string assembleCmd()
  709. {
  710.     setOptionVars(false);
  711.  
  712.     // get the global history flag value
  713.     int $doHistory = `constructionHistory -q -tgl`;
  714.  
  715.     int $method = `optionVar -query extendCurveMethod`;
  716.     int $extendType = `optionVar -query extendCurveType`;
  717.     float $distance = `optionVar -query extendCurveDistance`;
  718.     float $toPointx = `optionVar -query extendCurveToPointX`;
  719.     float $toPointy = `optionVar -query extendCurveToPointY`;
  720.     float $toPointz = `optionVar -query extendCurveToPointZ`;
  721.  
  722.     int $start = `optionVar -query extendCurveStart`;
  723.     int $join = `optionVar -query extendCurveJoin`;
  724.     int $removeMultKnots = `optionVar -query extendCurveRemoveMultKnots`;
  725.     int $replaceOriginal = !`optionVar -q extendCurveKeepOriginal`;
  726.  
  727.  
  728.     // set up string for preset function call
  729.     // Note that extendCurvePresetArgList() takes a string array.
  730.     // The command will look something like:
  731.     //    extendCurvePresetArgList( "2", { "0", "1","0","1","1.5", .... ,"1","0"});
  732.     //
  733.     string $version = "\"2\"";
  734.     string $cmd = "extendCurvePresetArgList";
  735.     $cmd = $cmd + "( ";
  736.     $cmd = $cmd + $version;
  737.     $cmd = $cmd + ", {\"0\", \"" ;
  738.     $cmd = $cmd + $doHistory;
  739.     $cmd = $cmd + "\",\"";
  740.     $cmd = $cmd + $method;
  741.     $cmd = $cmd + "\",\"";
  742.     $cmd = $cmd + $extendType;
  743.     $cmd = $cmd + "\",\"";
  744.     $cmd = $cmd + $distance;
  745.     $cmd = $cmd + "\",\"";
  746.     $cmd = $cmd + $toPointx;
  747.     $cmd = $cmd + "\",\"";
  748.     $cmd = $cmd + $toPointy;
  749.     $cmd = $cmd + "\",\"";
  750.     $cmd = $cmd + $toPointz;
  751.     $cmd = $cmd + "\",\"";
  752.     $cmd = $cmd + $start;
  753.     $cmd = $cmd + "\",\"";
  754.     $cmd = $cmd + $join;
  755.     $cmd = $cmd + "\",\"";
  756.     $cmd = $cmd + $removeMultKnots;
  757.     $cmd = $cmd + "\",\"";
  758.     $cmd = $cmd + $replaceOriginal;
  759.     $cmd = $cmd + "\"} )";
  760.  
  761.     return $cmd;
  762. }
  763.  
  764. //
  765. //  Procedure Name:
  766. //      performExtendCurve
  767. //
  768. //  Description:
  769. //        Perform the optionBoxExample1 command using the corresponding 
  770. //        option values.  This procedure will also show the option box
  771. //        window if necessary as well as construct the command string
  772. //        that will invoke the optionBoxExample1 command with the current
  773. //        option box values.
  774. //
  775. //  Input Arguments:
  776. //      0 - Execute the command.
  777. //      1 - Show the option box dialog.
  778. //      2 - Return the command.
  779. //      3 - Show the tool option box dialog.
  780. //
  781. //  Return Value:
  782. //      None.
  783. //
  784. global proc string performExtendCurve(int $action, string $goToTool)
  785. {
  786.     int $inTheTool = false;
  787.     if( 3 == $action ) {
  788.         $action = 1;
  789.         $inTheTool = true;
  790.     }
  791.  
  792.     string $cmd = "";
  793.     switch ($action) {
  794.       case 0:
  795.         setOptionVars(false);
  796.         $cmd = `assembleCmd`;
  797.         eval($cmd);
  798.         break;
  799.  
  800.       case 1:
  801.         extendCurveOptions( $inTheTool, $goToTool );
  802.         break;
  803.  
  804.       case 2:
  805.       default:
  806.         setOptionVars (false);
  807.         $cmd = `assembleCmd`;
  808.         break;
  809.     }
  810.     return $cmd;
  811. }
  812.  
  813.